{% extends "blog/base.html" %}

{% load i18n %}

{% block head_title %}{% blocktrans %}Write a Blog Post{% endblocktrans %}{% endblock %}

{% block body %}

    <div id="basic-form">
        <fieldset>
            <legend>{% trans "Write a Blog Post" %}</legend>

            <form method="POST" action="" id="blog_form">
                <table align="center">
                    <tr><td colspan="2">{{ blog_form.non_field_errors }}</td></tr>
                    {% for field in blog_form %}
                        {% if field.errors %}<tr><td></td><td>{{ field.errors }}</td></tr>{% endif %}
                        {% ifequal field.name "tease" %}<tr style="display: none;" id="teaser">{% else %}<tr>{% endifequal %}
                            <td width="150px" valign="top">{{ field.label_tag }}
                                    {% ifequal field.name "body" %}
                                    <a href="#" onclick="$('#teaser').toggle(); return false;">{% trans "Teaser" %}</a>
                                    {% endifequal %}
                            </td>
                            <td>{{ field }}</td></tr>
                        {% if field.help_text %}<tr><td colspan="2"><span>{{ field.help_text }}</span></td></tr>{% endif %}
                    {% endfor %}
                    <tr><td></td><td><input type="hidden" name="action" value="create" /><input type="submit" value="create" class="button"/></td></tr>
                </table>
            </form>
            </legend>
        </fieldset>
    </div>

{% endblock %}

{% block extra_body %}
    {% load jquery_validation %}
    {% include_validation %}
    <script type="text/javascript">
        $(function(){
            $('#blog_form').validate('{% url blog_form_validate %}', {type: 'table'});
        });
    </script>
{% endblock %}
